﻿function CreateSave() {
    if ($("#UCCIDCode").val() == "" || $("#UCCIDCode").val() == null) {
        abp.message.warn("请填写卡号");
        return;
    }
    var _url = "/Card/CardCreateForm";
    var message = "创建成功!";
    var newAgent = {
        UCCID: $("#UCCIDCode").val(),
        Remark: $("#RemarkId").val()
    };

    if ($("#CardId").val() != "0") {
        newAgent.Id = $("#CardId").val();
        newAgent.Status = $("#StatusId").val();
        newAgent.AgentCode = $("#AgentCodeId").val();
        newAgent.Package = $("#PackageId").val();
        newAgent.Balance = $("#BalanceId").val();
        newAgent.Proportion = $("#ProportionId").val();
        newAgent.Invalid_time = $("#Invalid_timeId").val();
        newAgent.BindTel = $("#BindTelId").val();
        newAgent.BindTime = $("#BindTimeId").val();
        newAgent.BindName = $("#BindNameId").val();
        newAgent.BindIdCard = $("#BindIdCardId").val();
        _url = "/Card/CardUpdateForm";
        message = "更新成功！";
    }
    abp.ajax({
        url: _url,
        data: JSON.stringify(newAgent)
    }).done(function (data) {
        if (data.status == true) {
            abp.message.success(data.errormsg);
        }
        if (data.status == false) {
            abp.message.warn(data.errormsg);
        }
    });
}

$(function () {
    //$('#Invalid_timeId').dcalendarpicker({ format: 'yyyy-mm-dd' }); //初始化预计签约日期选择器
    //$('#BindTimeId').dcalendarpicker({ format: 'yyyy-mm-dd' }); //初始化要求日期选择器
    $(function () {
        $('#Invalid_timeId').datepicker({
            format: 'yyyy-mm-dd hh:mm:ss',
            language: 'cn',
            pickDate: true,
            pickTime: true,
            inputMask: true,
            pickerPosition: "bottom-right",
            autoclose: true
        });
        $('#BindTimeId').datepicker({
            format: 'yyyy-mm-dd hh:mm:ss',
            language: 'cn',
            pickDate: true,
            pickTime: true,
            inputMask: true,
            pickerPosition: "bottom-left",
            autoclose: true
        });

    });

})
////清空日期选择日期
//function clearPicker() {
//    $('#PredictContract').val(""); //初始化预计签约日期选择器
//}
//必选的表单文本颜色
function OnFocusChangeColor(t) {
    if (t.id == "Invalid_timeId" || t.id == "BindTimeId") {
        $("#" + t.id).parent().parent().parent().attr("class", "form-group form-md-line-input form-group form-md-line-input has-error");
    } else {
        $("#" + t.id).parent().parent().attr("class", "form-group form-md-line-input form-group form-md-line-input has-error");
    }
    //$("#" + t.id).parent().parent().attr("class", "form-group form-md-line-input form-group form-md-line-input has-error");
    console.info($("#" + t.id).parent(".col-md-3"));
}
//恢复原有颜色
function OnBlurChangeColor(t) {
    if (t.id == "Invalid_timeId" || t.id == "BindTimeId") {
        $("#" + t.id).parent().parent().parent().attr("class", "form-group form-md-line-input");
    } else {
        $("#" + t.id).parent().parent().attr("class", "form-group form-md-line-input");
    }
}